//
//  VIPSignalingHelper.m
//  TTProduct
//
//  Created by My mac on 2018/8/22.
//  Copyright © 2018年 TTProduct. All rights reserved.
//

#import "VIPSignalingHelper.h"
#import "VIPSignalingJSON.h"
#import "NSDictionary+VIPExtension.h"

@implementation VIPSignalingHelper

+ (NSString *)signalingWithSource:(NSString *)source type:(NSString *)type subType:(NSString *)subType uid:(NSUInteger)uid {
    VIPSignalingModel *messageModel = [VIPSignalingModel new];
    VIPWinSubSignalingModel *subSignalingModel = [VIPWinSubSignalingModel new];
    subSignalingModel.opType2 = subType;
    subSignalingModel.opParam2 = source;
    subSignalingModel.uID = uid;
    
    messageModel.opType1 = type;
    messageModel.opParam1 = subSignalingModel;
    NSString *json = [VIPSignalingJSON JSONWithSignaling:messageModel];
    NSLog(@"json: %@", json);
    
    return json;
}

+ (NSString *)signalingWithOpJsonParam2:(NSDictionary *)opJsonParam2 type:(NSString *)type subType:(NSString *)subType uid:(NSUInteger)uid {
    VIPSignalingModel *messageModel = [VIPSignalingModel new];
    VIPWinSubSignalingModel *subSignalingModel = [VIPWinSubSignalingModel new];
    subSignalingModel.opType2 = subType;
    subSignalingModel.opJsonParam2 = opJsonParam2;
    subSignalingModel.uID = uid;
    subSignalingModel.fromID = uid;

    messageModel.opType1 = type;
    messageModel.opParam1 = subSignalingModel;
    NSString *json = [VIPSignalingJSON JSONWithSignaling:messageModel];
    NSLog(@"json: %@", json);
    
    return json;
}

+ (NSString *)signalingType:(NSString *)type uid:(NSUInteger)uid currentState:(NSString *)state {
    VIPSignalingModel *messageModel = [VIPSignalingModel new];
    VIPWinSubSignalingModel *subSignalingModel = [VIPWinSubSignalingModel new];
    subSignalingModel.fromID = uid;
    subSignalingModel.loginState = state;
    
    messageModel.opType1 = type;
    messageModel.opParam1 = subSignalingModel;
    NSString *json = [VIPSignalingJSON JSONWithSignaling:messageModel];
    NSLog(@"json: %@", json);
    
    return json;
}

+ (NSString *)signalingType:(NSString *)opType subType:(NSString *)subType uid:(NSUInteger)uid recvID:(NSInteger)recvID msgType:(NSInteger)msgType excitationUid:(NSArray *)excitationUid giftID:(NSString *)giftID type:(NSInteger)type data:(NSArray *)data {
    
    NSMutableDictionary *opParam2 = [NSMutableDictionary dictionary];
    opParam2[@"MsgType"] = @(msgType);
    opParam2[@"ExcitationUid"] = excitationUid;
    opParam2[@"GiftID"] = giftID;
    opParam2[@"type"] = @(type);
    opParam2[@"data"] = data;
    
    VIPWinSubSignalingModel *subSignalingModel = [VIPWinSubSignalingModel new];
    subSignalingModel.fromID = uid;
    subSignalingModel.recvID = recvID;
    subSignalingModel.opParam2 = opParam2.tt_json;
    subSignalingModel.opType2 = subType;
    
    VIPSignalingModel *messageModel = [VIPSignalingModel new];
    messageModel.opType1 = opType;
    messageModel.opParam1 = subSignalingModel;
    NSString *json = [VIPSignalingJSON JSONWithSignaling:messageModel];
    NSLog(@"json: %@", json);
    
    return json;
}

+ (NSString *)signalingType:(NSString *)opType subType:(NSString *)subType uid:(NSUInteger)uid recvID:(NSInteger)recvID msgType:(NSInteger)msgType LogState:(NSInteger)logState{
    NSMutableDictionary *opParam2 = [NSMutableDictionary dictionary];
    opParam2[@"MsgType"] = @(msgType);
    opParam2[@"LogState"] = @(logState);
    
    VIPWinSubSignalingModel *subSignalingModel = [VIPWinSubSignalingModel new];
    subSignalingModel.fromID = uid;
    subSignalingModel.recvID = recvID;
    subSignalingModel.opParam2 = opParam2.tt_json;
    subSignalingModel.opType2 = subType;

    VIPSignalingModel *messageModel = [VIPSignalingModel new];
    messageModel.opType1 = opType;
    messageModel.opParam1 = subSignalingModel;
    NSString *json = [VIPSignalingJSON JSONWithSignaling:messageModel];
    NSLog(@"json: %@", json);
    return json;
}

+ (NSString *)signalingWithSource:(NSString *)source type:(NSString *)type subType:(NSString *)subType {
    return [self signalingWithSource:source type:type subType:subType uid:0];
}

@end
